//
// Created by yunnan xu on 2020/11/25.
//

#ifndef ANDROIDGRAPHICSDEMOS_MODEL_H
#define ANDROIDGRAPHICSDEMOS_MODEL_H


#include <memory>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include "glm.hpp"
#include "VertexAttrib.h"

class Texture;

namespace Phy{
    class RigidBody;
}

class Model{

public:
    Model();
    virtual ~Model();

    virtual int GetVertexNumber() const = 0;
    virtual int GetFaceNumber() const = 0;
    virtual const void * GetVertexData(VertexAttribType attrib_type) const = 0;
    virtual size_t GetVertexDataLength(VertexAttribType attrib_type) const = 0;
    virtual const void * GetIndexData() const = 0;
    virtual size_t GetIndexDataLength() const = 0;
    virtual GLenum GetIndexType() const = 0;

    const glm::mat4 & GetModelMatrix() const;
    void SetModelMatrix(glm::mat4 mat);
    void SetTranslation(glm::vec3 translation, bool sync_to_rb = true);
    void SetRotation(glm::vec3 rotation, bool sync_to_rb = true);
    void SetScale(glm::vec3 scale, bool sync_to_rb = true);

    void SetTranslation(glm::mat4 mat, bool sync_to_rb = true);
    void SetRotation(glm::mat4 mat, bool sync_to_rb = true);
    void SetScale(glm::mat4 mat, bool sync_to_rb = true);

    glm::mat4 GetTranslationMat() const;
    glm::mat4 GetRotationMat() const;
    glm::mat4 GetScaleMat() const;

    std::shared_ptr<Phy::RigidBody> GetRB();

protected:

    glm::mat4 transform{};
    std::shared_ptr<Phy::RigidBody> rb;
    glm::mat4 translation_mat{};
    glm::mat4 rotate_mat{};
    glm::mat4 scale_mat{};
};

#endif //ANDROIDGRAPHICSDEMOS_MODEL_H
